{extend name="common/base" /}
{block name="nav_title"}

<a href="javascript:;" onclick="sqlback()" class="layui-btn layui-btn-normal layui-btn-sm rha-nav-title" >备份数据库</a>
{/block}
{block name="body"}
<div style="padding: 0px 10px 0px 10px;">
    <table class="layui-table" lay-even="" lay-skin="nob">

        <thead>
        <tr>
            <th>ID</th>
            <th width="50%">备份路径</th>
            <th>管理员</th>
            <th>日期</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="list" id="vo"}
        <tr>
            <td>{$vo.id}</td>
            <td>{$vo.path}</td>
            <td>{$vo.admin_name}</td>
            <td>{$vo.create_time}</td>
            <td>
                <a class="rha-bt-a" onclick="deleteBackRecord('{$vo.id}')" href="javascript:;">删除</a>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
</div>
{$page|raw}
<script>
    function sqlback() {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.confirm('你确定备份数据库吗？', {
                btn: ['是','不'] //按钮
            }, function(){

                $.post("{:url('backupSql')}",{},function (res) {

                    layer.msg('备份成功');
                    window.location.reload();
                })
            })
        });

    }

    function deleteBackRecord(id) {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.confirm('你确定需要删除吗？', {
                btn: ['是','不'] //按钮
            }, function(){
                $.post("{:url('deleteBackRecord')}",{'id':id},function (res) {
                    layer.alert('删除成功',function (index) {
                        window.location.reload();
                        layer.close(index);
                    })
                })
            })
        });

    }

</script>
{/block}